package com.engine;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class SaveConfig {
	static String fileprops="ticketsq.props";
	static Properties props;
	static SaveConfig INSTANCE=null;
	private static void createInstance(String fileprops) throws FileNotFoundException, IOException
	{
		INSTANCE=new SaveConfig(fileprops);
	}
	public synchronized static SaveConfig getInstance(String fileprops) throws FileNotFoundException, IOException
	{
		if(INSTANCE==null) createInstance(fileprops);
		return INSTANCE;
	}
	
	public synchronized static void removeInstance()
	{
		INSTANCE=null;
	}
	
	private SaveConfig(String fileprops) throws FileNotFoundException, IOException
	{
		if(fileprops!=null)
			SaveConfig.fileprops = fileprops;
		props=new Properties();
		props.load(new FileInputStream(SaveConfig.fileprops));
	}
	
	public static void PUT(String key,String value)
	{
		props.put(key,value);
	}
	public static void Close() throws FileNotFoundException, IOException
	{
		props.store(new FileOutputStream(fileprops),null);
	}
}
